package com.dkt.android.api

import android.R.attr.password
import com.dkt.android.base.BaseRsps
import com.dkt.android.mvp.model.BackUserInfo
import com.dkt.android.mvp.model.IndexShopBean
import com.dkt.android.mvp.model.LoginInfo
import io.reactivex.Observable
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Response


/**
 * @author: dtb
 * @email: wendaoyuqin1@gmail.com
 * @createTime: 19-3-14上午11:44
 */
object UserApiService {

    private val userApiService by lazy {
        ApiService.getService().create(api::class.java)
    }


    fun login(bean: LoginInfo): Observable<Response<BaseRsps<BackUserInfo?>>> {
        val multipartBody: MultipartBody = MultipartBody.Builder().setType(MultipartBody.FORM)
            .addFormDataPart("username", bean.account)
            .addFormDataPart("password", bean.pwd)
            .build()
        return userApiService.login(multipartBody)
    }

    fun itemList(page:String,name:String): Observable<Response<BaseRsps<List<IndexShopBean>>>> {
        return userApiService.itemList(page,name)
    }

}